import { User } from 'src/user/entities/user.entity';
import { Entity, PrimaryGeneratedColumn, ManyToOne, Unique } from 'typeorm';
import { Comment } from './comment.entity';

@Entity({ name: 'comment_likes' })
@Unique(['user', 'comment'])
export class CommentLikes {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => User, (user) => user.commentLikes)
  user: User;

  @ManyToOne(() => Comment, (comment) => comment.commentLikes, {
    onDelete: 'CASCADE',
  })
  comment: Comment;
}
